package com.yidu.t299.service.lzy.impl;

import com.yidu.t299.dao.lzy.SourcesettingMapper;
import com.yidu.t299.domain.lzy.SourceSetting;
import com.yidu.t299.service.lzy.SourcesettingBiz;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class SourcesettingBizImpl implements SourcesettingBiz {
    @Autowired
    private SourcesettingMapper sourcesettingMapper;



    @Override
    public int deleteByPrimaryKey(Integer sourceId) {
        return sourcesettingMapper.deleteByPrimaryKey(sourceId);
    }

    @Override
    public int insert(SourceSetting record) {
        return sourcesettingMapper.insert(record);
    }

    @Override
    public SourceSetting selectByPrimaryKeys(Integer sourceId) {
        return sourcesettingMapper.selectByPrimaryKey(sourceId);
    }

    @Override
    public List<SourceSetting> selectByPage(int rows, int page, String condition) {
        return sourcesettingMapper.selectByPage(rows, page, condition);
    }

    @Override
    public int selectCount(String condition) {
        return sourcesettingMapper.selectCount(condition);
    }

    @Override
    public int updateByPrimaryKey(SourceSetting record) {
        return sourcesettingMapper.updateByPrimaryKey(record);
    }

    @Override
    public String getCondition(SourceSetting record) {
        // 定义条件字符串变量，初始值为空格字符串
        String condition = " ";
        // 如果校区对象为空，则直接返回空条件字符串
        if (record == null) {
            return condition;
        }
        // 如果校区名称不为空
        if (record.getSourceName() != null && record.getSourceName().trim().length() != 0) {
            condition += " and source_name like '%" + record.getSourceName() + "%'";
        }
        System.out.println(condition);
        return condition;
    }
}
